<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>15-样式绑定之class绑定数组用法</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <style>
      .current {
        background-color: yellow;
      }
      .borderStyle {
        border: 2px solid red !important;
      }
      .box {
        border: 1px solid #ccc;
        width: 100px;
        height: 100px;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <div class="box" v-bind:class="[flag1, flag2]"></div>
      <button @click="btn">点击改变</button>
    </div>
    <script>
      Vue.config.keyCodes.hello = 65; // 65表示a， 只有按下a才会触发
      var vm = new Vue({
        el: '#app',
        data: {
          flag1: 'current',
          flag2: 'borderStyle',
        },
        methods: {
          btn: function () {
            this.flag1 = '';
            this.flag2 = '';
          },
        },
      });
    </script>
  </body>
</html>
